package com.poly.system.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference;

@Getter
@RequiredArgsConstructor
public enum AppMenuAuthTypeEnum {
    DEPT(1,"部门"),
    ROLE(2,"角色"),
    USER(3,"用户");


    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 通过值获取名称
     *
     * @param value
     * @return
     */
    public static String getName(Integer value) {
        AtomicReference<String> nameStr = new AtomicReference<>();
        Arrays.asList(values()).forEach(p -> {
            if (p.getValue().equals(value)) {
                nameStr.set(p.getName());
            }
        });
        return nameStr.get();
    }
}
